﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;

// -----------------------------------------------------------------------
// <copyright file="$safeitemrootname$.cs" company="$registeredorganization$">
// TODO: Update copyright text.
// </copyright>
// -----------------------------------------------------------------------
namespace NewGame
{
    public abstract class PerspectiveCamera : MyCamera
    {
        protected float _NearPlaneDistance;

        public float NearPlaneDistance
        {
            get { return _NearPlaneDistance; }
            set { _NearPlaneDistance = value; }
        }
        protected float _FarPlaneDistance;

        public float FarPlaneDistance
        {
            get { return _FarPlaneDistance; }
            set { _FarPlaneDistance = value; }
        }
        protected float _AspectRatio;

        public float AspectRatio
        {
            get { return _AspectRatio; }
            set { _AspectRatio = value; }
        }
        protected float _FieldOfView;

        public float FieldOfView
        {
            get { return _FieldOfView; }
            set { _FieldOfView = value; }
        }

        protected float _rotationY;

        public float RotationY
        {
            get { return _rotationY; }
            set { _rotationY = value; }
        }

        public void initCamera(
            Vector3 cameraPosition,
            Vector3 cameraTarget,
            Vector3 cameraUpVector,
            float nearPlaneDistance,
            float farPlaneDistance,
            float fieldOfView,
            float aspectRatio)
        {
            CameraPosition = cameraPosition;
            CameraTarget = cameraTarget;
            CameraUpVector = cameraUpVector;
            NearPlaneDistance = nearPlaneDistance;
            FarPlaneDistance = farPlaneDistance;
            FieldOfView = fieldOfView;
            AspectRatio = aspectRatio;
            internalInitMatrix();
        }

        private void internalInitMatrix()
        {
            View = Matrix.CreateLookAt(CameraPosition, CameraTarget, CameraUpVector);
            Projection = Matrix.CreatePerspectiveFieldOfView(FieldOfView, AspectRatio, NearPlaneDistance, FarPlaneDistance);
        }

        public override void Update(GameTime gameTime)
        {
            internalInitMatrix();
            //base.Update(gameTime);
        }
    }
}
